<!-- 导航栏 -->
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- 导航栏首部 -->
    <div class="navbar-header">
      <!-- Logo -->
      <%= link_to image_tag("logo.png", alt:"Milog", class: "logo"), root_path, class: "navbar-brand" %>
      <!-- 切换语系 -->
      <%= link_to_locale request.path, mclass: "navbar-text switch-lang" %>

      <%= content_tag(:span, "#{capitalize_name(@user)}'s Blog", class: "navbar-text ") if current_user != @user %>
      <!-- 屏幕<=420px时显示 -->
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#collapse-nav">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <!-- 已登录, 显示操作菜单 -->
    <% if signed_in? %>
      <ul class="nav navbar-nav navbar-right navbar-footer drop-nav" >
        <!-- 后台操作 -->
        <% if current_user.admin? %>
        <li>
          <%= link_to content_tag(:i, '', class: 'glyphicon glyphicon-console header-console'), admin_index_path, title: t('console') %>
        </li>
        <% end %>
        <!-- 新建类操作 -->
        <li class="dropdown dropdown-opt">
          <a class="dropdown-toggle" data-toggle="dropdown" role="button" >
            <span class="glyphicon glyphicon-plus"></span>
            <span class="caret"></span>
          </a>
          <ul class="dropdown-menu">
            <%= content_tag :li, link_to(t("new_blog"), new_article_path) %>
            <%= content_tag :li, link_to(t("edit_resume"), resume_edit_user_path(@user.username)) %>
          </ul>
        </li>
        <!-- 设置类操作 -->
        <li class="dropdown dropdown-setting">
          <a class="dropdown-toggle" data-toggle="dropdown" role="button" >
            <!-- 头像 -->
            <%= avatar_tag current_user, :xs %>
            <span class="caret"></span>
          </a>
          <ul class="dropdown-menu">
            <%= content_tag :li, link_to(capitalize_name(current_user), user_path(current_user.username)) %>
            <%= content_tag :li, content_tag(:div, '', class:"divider") %>
            <%= content_tag :li, link_to(t("account_profile"), edit_account_path) %>
            <%= content_tag :li, link_to(t("resume"), resume_user_path(@user.username)) %>
            <%= content_tag :li, link_to(t("drafts"), drafts_user_path(@user.username)) %>
            <%= content_tag :li, content_tag(:div, '', class:"divider") %>
            <%= content_tag :li, link_to(t("signout"), signout_path, method: 'delete') %>
          </ul>
        </li>
      </ul>
    <% else %>
      <!-- 登录注册 -->
      <div class="navbar-right navbar-footer login-group">
        <%= link_to t("signup"), signup_path, class: "navbar-text" %>
        <%= link_to t("signin"), signin_path, class: "navbar-text" %>
      </div>
    <% end %>
    
    <!-- 主菜单项 -->
    <% if yield(:inadmin).blank? %>
    <div class="collapse navbar-collapse" id="collapse-nav">
      <ul class="nav navbar-nav navbar-center main-nav">
        <%= content_tag :li, link_to(t("home"), user_path(@user.username)) %>
        <%= content_tag :li, link_to(t("category"), categories_user_path(@user.username)) %>
        <%= content_tag :li, link_to(t("archive"), archive_user_path(@user.username)) %>
        <%= content_tag :li, link_to(t("aboutme"), aboutme_user_path(@user.username)) %>
        <%= content_tag :li, link_to(t("search"), "#", id: 'search') %>
      </ul>
    </div>
    <% end %>
  </div>
</nav>